﻿<Window x:Class="SimpleTcpSocketWPF.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:avalonedit="clr-namespace:ICSharpCode.AvalonEdit;assembly=ICSharpCode.AvalonEdit"
        xmlns:properties="clr-namespace:SimpleTcpSocketWPF.Properties"
        xmlns:converters="clr-namespace:JFKCommonLibrary.WPF.Converters;assembly=JFKCommonLibrary"
        Title="TCP-Socket (Version 3.13)" Height="573" Width="812">
    <Window.Resources>
        <ObjectDataProvider x:Key="settings" ObjectType="{x:Type properties:Settings}"></ObjectDataProvider>
    </Window.Resources>
    <Grid Background="#FFE4E4E4" DataContext="{Binding Source={x:Static properties:Settings.Default}}">
        <TextBox Visibility="{Binding Active, Converter={converters:BoolToVisibilityConverter}}" HorizontalAlignment="Left" Margin="41,14,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="270" Height="22" RenderTransformOrigin="0.288,0.501" Text="{Binding IP}"/>
        <Label Content="IP:" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="26"/>

        <TabControl Margin="10,54,10,28">
            <TabItem Header="Logger">
                <Grid>
                    <Border BorderBrush="Black" BorderThickness="1" Margin="0,0,0,20">
                        <avalonedit:TextEditor x:Name="txtRecieve"
                                   HorizontalAlignment="Stretch"
                                   VerticalAlignment="Stretch"
                                  
                                   FontFamily="Courier New"
                                   FontSize="13"
                                   IsReadOnly="True"                                   
                                   ShowLineNumbers="True"                                   
                                   Visibility="Visible" />
                    </Border>
                    <CheckBox x:Name="chkLoggerRefresh"  VerticalAlignment="Bottom" Content="Refresh" IsChecked="True" Checked="chkLoggerRefresh_Checked" />
                </Grid>
            </TabItem>
            <TabItem Header="Sender" Height="23" VerticalAlignment="Top">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="35" />
                        <RowDefinition Height="35" />
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Border BorderBrush="Black" Grid.Row="2" BorderThickness="1">
                        <avalonedit:TextEditor Margin="0,0,0,5"  x:Name="txtSended"
                                   HorizontalAlignment="Stretch"
                                   VerticalAlignment="Stretch"
                                   BorderBrush="DarkGray"
                                   BorderThickness="1"
                                   FontFamily="Courier New"
                                   FontSize="13"
                                   IsReadOnly="True"                                   
                                   ShowLineNumbers="True"                                   
                                   Visibility="Visible" Grid.ColumnSpan="2" />
                    </Border>
                    <Border BorderBrush="Black" Grid.Row="3" BorderThickness="1">
                        <avalonedit:TextEditor  x:Name="txtRecieve2"
                                   HorizontalAlignment="Stretch"
                                   VerticalAlignment="Stretch"
                                   BorderBrush="DarkGray"
                                   BorderThickness="1"
                                   FontFamily="Courier New"
                                   FontSize="13"
                                   IsReadOnly="True"                                   
                                   ShowLineNumbers="True"                                   
                                   Visibility="Visible" Grid.ColumnSpan="2" />
                    </Border>
                    <GridSplitter Grid.Row="2" Background="#FFE4E4E4" Opacity="0.8" VerticalAlignment="Bottom" Height="5" HorizontalAlignment="Stretch" Grid.ColumnSpan="2" />
                    <TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Text="Telegramm: " Margin="27,10,0,0"/>
                    <TextBlock Text="Telegramm (HEX): " Margin="0,10,0,0" Grid.Row="1" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" Width="98"/>
                    <TextBox x:Name="txtTelegramm" Grid.Row="0" Margin="98,5,170,5" TextWrapping="Wrap" RenderTransformOrigin="0.288,0.501" TextChanged="txtTelegramm_TextChanged" MouseDoubleClick="txtTelegramm_MouseDoubleClick" MouseUp="txtTelegramm_MouseUp" KeyDown="txtTelegramm_KeyDown"/>
                    <TextBox x:Name="txtTelegrammHex" Grid.Row="1" Margin="98,5,0,5" TextWrapping="Wrap" RenderTransformOrigin="0.288,0.501" PreviewTextInput="txtTelegrammHex_PreviewTextInput" PreviewKeyDown="txtTelegrammHex_PreviewKeyDown" TextChanged="txtTelegrammHex_TextChanged" KeyDown="txtTelegrammHex_KeyDown" />

                    <Button x:Name="cmdSend" Grid.Row="0" Margin="0,5" Content="Send" Click="cmdSend_Click" HorizontalAlignment="Right" Width="91" MouseDown="cmdSend_MouseDown" />
                    <Label x:Name="blLen" BorderBrush="Black" BorderThickness="1" Margin="0,5,96,5" HorizontalAlignment="Right" Width="69"  />
                </Grid>
            </TabItem>
            <TabItem Header="Advanced Options">
                <Grid>
                    <ComboBox x:Name="cbEncoding" HorizontalAlignment="Left" Height="24" Margin="86,113,0,0" VerticalAlignment="Top" Width="159"/>
                    <Label Content="Encoding:" HorizontalAlignment="Left" Margin="13,113,0,0" VerticalAlignment="Top" Width="68" RenderTransformOrigin="2.714,1.808"/>
                    <CheckBox Content="Show Date" HorizontalAlignment="Left" Margin="11,19,0,0" VerticalAlignment="Top" IsChecked="{Binding ShowDate}"/>
                    <CheckBox Content="Show Length" HorizontalAlignment="Left" Margin="11,36,0,0" VerticalAlignment="Top" IsChecked="{Binding ShowRecievedLen}"/>
                    <CheckBox Content="Escape Special Chars" HorizontalAlignment="Left" Margin="11,53,0,0" VerticalAlignment="Top" IsChecked="{Binding EscapeSpecialChars}"/>
                    <CheckBox Content="Log Data as Hex-Bytes" HorizontalAlignment="Left" Margin="11,70,0,0" VerticalAlignment="Top" IsChecked="{Binding LogDataAsHexBytes}"/>
                    <CheckBox x:Name="chkAnswer" Content="Automaticly send an Answer Telegram" HorizontalAlignment="Left" Margin="13,206,0,0" VerticalAlignment="Top" IsChecked="{Binding LogDataAsHexBytes}"/>
                    <CheckBox Content="Mirror Recieved Telegram" HorizontalAlignment="Left" Margin="13,226,0,0" VerticalAlignment="Top" IsChecked="{Binding EscapeSpecialChars}"/>
                    <TextBox Margin="13,246,535,164.6" Text="2;SR01MFC1" />
                </Grid>
            </TabItem>
        </TabControl>
        <TextBox HorizontalAlignment="Left" Margin="363,15,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="70" RenderTransformOrigin="0.957,0.455" Text="{Binding Port}"/>
        <Label Content="Port:" HorizontalAlignment="Left" Margin="316,11,0,0" VerticalAlignment="Top" Width="42"/>
        <CheckBox x:Name="___No_Name_" Content="Active" HorizontalAlignment="Left" Margin="447,16,0,0" VerticalAlignment="Top" IsChecked="{Binding Active, Mode=TwoWay}"/>
        <Button x:Name="cmdConnect" Content="Connect" HorizontalAlignment="Left" Margin="512,13,0,0" VerticalAlignment="Top" Width="116" Height="24" Click="cmdConnect_Click"/>
        <Button x:Name="cmdSave" Content="Save" HorizontalAlignment="Right" Margin="0,15,10,0" VerticalAlignment="Top" Width="75" Click="cmdSave_Click"/>
        <StatusBar HorizontalAlignment="Stretch" Height="25" VerticalAlignment="Bottom">
            <StatusBarItem DockPanel.Dock="Right">
                <TextBlock Name="lblLogFile" />
            </StatusBarItem>
            <StatusBarItem>
                <TextBlock Name="lblException" />
            </StatusBarItem>
        </StatusBar>
        <Label Content="all" BorderBrush="Black" BorderThickness="1" HorizontalContentAlignment="Center"  Visibility="{Binding Active, Converter={converters:BoolToVisibilityConverter FalseValue=Visible, TrueValue=Hidden}}" VerticalContentAlignment="Center" Padding="0"  HorizontalAlignment="Left" Margin="41,14,0,0" VerticalAlignment="Top" Width="125" Height="22"/>
        <CheckBox Visibility="{Binding LogDataAsHexBytes, Converter={converters:BoolToVisibilityConverter}}" Content="Hex &amp; Ascii" HorizontalAlignment="Left" Margin="637,54,-13,0" VerticalAlignment="Top" IsChecked="{Binding LogHexAndAscii}"/>

    </Grid>
</Window>
